package com.community.tool;

import com.community.pojo.dto.AdminQueryDto;
import com.community.pojo.dto.ParkingAIQueryDto;
import com.community.pojo.dto.ParkingQueryDto;
import com.community.pojo.entity.Admin;
import com.community.pojo.entity.Parking;
import com.community.pojo.entity.Village;
import com.community.pojo.vo.ParkingListVo;
import com.community.service.AdminService;
import com.community.service.ParkingService;
import com.community.service.VillageService;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AITools {

    @Autowired
    private VillageService villageService;

    @Autowired
    private ParkingService parkingService;
    @Autowired
    private AdminService adminService;

    @Tool(description = "查询所有小区")
    public List<Village> findVillageAll(){
        return villageService.list();
    }

    @Tool(description = "查询所有车位")
    public List<Parking> findParkingListAll(@ToolParam ParkingQueryDto parkingQueryDto){
        return parkingService.list();
    }

    @Tool(description = "查询所有用户")
    public List<Admin> findAdminListAll(@ToolParam AdminQueryDto adminQueryDto){
        return adminService.list();
    }


    @Tool(description = "根据条件查询车位信息")
    public List<ParkingListVo> findParkingByAIQueryDto(@ToolParam(description = "查询条件") ParkingAIQueryDto parkingAIQueryDto){
        return parkingService.findParkingByAIQueryDto(parkingAIQueryDto);
    }

    @Tool(description = "添加车位")
    public Boolean insertParking(@ToolParam(description = "小区id") Long villageId, @ToolParam(description = "车位名称") String name,
                                 @ToolParam(description = "车位编号") String number,@ToolParam(description = "车位状态") Integer status){
        Parking parking = new Parking();
        parking.setName(name);
        parking.setNumber(number);
        parking.setVillageId(Math.toIntExact(villageId));
        parking.setStatus(status);
        return parkingService.save(parking);
    }


}